home *** CD-ROM | disk | FTP | other *** search
- /* mciplay.cpp
-
- A simple function to send the playback time back to the main window and
- handle seeks. This operates using the MCI command strings, and assumes
- that a sound file aliased "sounder" is already loaded. Written by
- Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu).
-
- Last modified : 01/28/97 */
-
- #define STRICT
- #include <windows.h>
-
- #include "str_lib.h"
- #include "args.h"
- #include "mp2win.h"
-
- DWORD mciplay (MCI_Args *args)
- {
- char mci_buffer[1024];
- char mci_command[256];
- char ms_buffer[32];
-
- HANDLE mutex = args->mutex;
-
- while(TRUE) {
-
- WaitForSingleObject(mutex, INFINITE);
- if (args->stop) {
- args->done = TRUE;
- ReleaseMutex(mutex);
- return(0);
- }
-
- // Handle seeks
-
- if (args->position_change) {
-
- mciSendString("stop sounder", mci_buffer, 1024, NULL);
- lstrcpy(mci_command, "seek sounder to ");
- lstrcat(mci_command, my_itoa(args->desired_position,
- ms_buffer, 10));
- lstrcat(mci_command, " wait");
- mciSendString(mci_command, mci_buffer, 1024, NULL);
-
- if (args->playing)
- mciSendString("play sounder notify", mci_buffer, 1024, args->hWnd);
-
- args->position_change = FALSE;
-
- PostMessage(args->hWnd, SEEK_ACK, 0, 0);
- ReleaseMutex(mutex);
-
- } else {
- ReleaseMutex(mutex);
- Sleep(100);
- }
-
- // Update the scroll bar
- mciSendString("status sounder position", mci_buffer, 1024, NULL);
- PostMessage(args->hWnd, SCROLL_POS, my_atoi(mci_buffer), 0);
- }
- }
-
-
-